package com.zrkizzy.seckill.controller.system;

import com.zrkizzy.seckill.entity.User;
import com.zrkizzy.seckill.enums.HttpStatusEnum;
import com.zrkizzy.seckill.service.core.IOrderService;
import com.zrkizzy.seckill.vo.common.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 订单表 前端控制器
 * </p>
 *
 * @author zhangrongkang
 * @since 2023-03-22
 */
@RestController
@RequestMapping("/order")
public class OrderController {

    @Autowired
    private IOrderService orderService;

    /**
     * 获取订单详情
     *
     * @param user 用户对象
     * @param orderId 订单Id
     * @return 前端响应对象
     */
    @GetMapping("/detail")
    public Result detail(User user, Long orderId) {
        // 判断用户信息
        if (null == user) {
            return Result.error(HttpStatusEnum.USER_EXIST_ERROR);
        }
        return Result.success(orderService.detail(orderId));
    }
}
